Added a pages_to_kib function, which converts a page count into a number of
authoremellor@leeni.uk.xensource.com <emellor@leeni.uk.xensource.com>
Thu, 1 Dec 2005 03:19:40 +0000 (03:19 +0000)
committeremellor@leeni.uk.xensource.com <emellor@leeni.uk.xensource.com>
Thu, 1 Dec 2005 03:19:40 +0000 (03:19 +0000)
KiB.  This allows us to compute the correct amount to balloon out to support
a migration.

Signed-off-by: Ewan Mellor <ewan@xensource.com>
tools/python/xen/lowlevel/xc/xc.c

index 29f64641d685cd692a62edbc85bf75f5ed9f71cd..95b0a9f101428ca72dd02a8c1566560fb129e247 100644 (file)
@@ -576,6 +576,17 @@ static PyObject *pyxc_readconsolering(XcObject *self,
 }
 
 
+static PyObject *pyxc_pages_to_kib(XcObject *self, PyObject *args)
+{
+    unsigned long pages;
+
+    if (!PyArg_ParseTuple(args, "l", &pages))
+        return NULL;
+
+    return PyLong_FromUnsignedLong(pages * (XC_PAGE_SIZE / 1024));
+}
+
+
 static unsigned long pages_to_mb(unsigned long pages)
 {
     return (pages * (XC_PAGE_SIZE / 1024) + 1023) / 1024;
@@ -1059,6 +1070,12 @@ static PyMethodDef pyxc_methods[] = {
       " allow_access [int]: Non-zero means enable access; else disable access\n\n"
       "Returns: [int] 0 on success; -1 on error.\n" },
 
+    { "pages_to_kib",
+      (PyCFunction)pyxc_pages_to_kib,
+      METH_VARARGS, "\n"
+      "Returns: [int]: The size in KiB of memory spanning the given number "
+      "of pages.\n" },
+
     { NULL, NULL, 0, NULL }
 };